package com.itheima;

import com.itheima.pojo.Address;
import com.itheima.pojo.Result;
import com.itheima.pojo.User;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

@RestController
public class ResultResponseController {

    @RequestMapping("/getAllUsers")
    public Result getUsers() {
        Address address = new Address();
        address.setProvince("福建省");
        address.setCity("厦门市");

        User user = new User();
        user.setName("张三");
        user.setAge(18);
        user.setAddress(address);

        //集合创建保存多个数据返回
        ArrayList<User> users = new ArrayList<>();
        users.add(user);
        users.add(user);
        users.add(user);
        users.add(user);

        return new Result(1, "获取成功", users);
    }

}
